﻿using MagicSir.DependencyInjection;
using MagicSir.MagicOptions;
using MagicSir.Options;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Runtime.CompilerServices;

namespace MagicSir.Core
{
    public static class MagicSirExtensions
    {
        public static IServiceCollection AddMagicSir(this IServiceCollection services)
        {
            services.AddOptions()
                .AddHttpContextAccessor()
                .AddDepencyInjection()
                .AddMagicOptions();
            return services;
        }
        public static IApplicationBuilder UseMagicSir(this IApplicationBuilder app)
        {

            MagicSirApp.ServiceProvider = app.ApplicationServices;
            MagicSirApp.HttpContextAccessor = MagicSirApp.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
            //app.UseMagicOptions();

            return app;
        }

    }
}
